﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using BUS;
using TuyenDungViecLam.CommonResource;

namespace TuyenDungViecLam.NguoiTimViec
{
    public partial class NopCVOnline : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                int userID = int.Parse(Session["UserID"].ToString());
                //int userID = 2;

                DlThongtinCV.DataSource = NguoiTimViec_BUS.LayThongTinCVOnline(userID.ToString());
                DlThongtinCV.DataBind();

            }

        }

        protected void DlThongtinCV_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                int Mct = int.Parse(Request.QueryString["Mct"].ToString());
                //int Mct = 2;

                Label tenNhaTuyenDung = (Label)e.Item.FindControl("LbNhaTuyenDung");
                tenNhaTuyenDung.Text = NhaTuyenDung_BUS.LayTenNhaTuyenDung(Mct, "");
            }
        }

        protected void BtGui_Click(object sender, EventArgs e)
        {
            int Mct = int.Parse(Request.QueryString["Mct"].ToString());
            //int Mct = 2;

            int userID = int.Parse(Session["UserID"].ToString());

            //int userID = 2;

            int kq = NguoiTimViec_BUS.GuiCVOnline(userID, Mct);

            if (kq == 1)
                Alert.ShowAndRedirect("Gửi thành công", "../../Default.aspx");
            else
                if (kq == 2)
                    Alert.Show("CV này đã được gửi cho nhà tuyển dụng này rồi");
                else
                    Alert.Show("Gửi thất bại");
        }
    }
}
